package com.lagou.edu.controller;

import com.lagou.edu.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author
 */
@CrossOrigin
@RequestMapping("/user")
@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/register/{email}/{password}/{code}")
    public Boolean register(@PathVariable String email, @PathVariable String password, @PathVariable String code){
        return userService.register(email, password, code);
    }

    @GetMapping("/isRegistered/{email}")
    public Boolean isRegistered(@PathVariable String email){
        return userService.isRegistered(email);
    }

    @GetMapping("/login/{email}/{password}")
    public String login(@PathVariable String email, @PathVariable String password){
        return userService.login(email, password);
    }

    @GetMapping("/info/{token}")
    public String info(@PathVariable String token){
        return userService.info(token);
    }

    @GetMapping("/createToken/{email}/{password}")
    public String createToken(@PathVariable String email, @PathVariable String password){
        return userService.createToken(email, password);
    }

}
